#ifndef SATURNOS_INC_TYPES_H
#define SATURNOS_INC_TYPES_H

#ifndef NULL
#define NULL ((void*) 0)
#endif

// Represents true-or-false values
typedef int bool;

// Explicitly-sized versions of integer types
typedef __signed char		int8_t;
typedef unsigned char		uint8_t;
typedef short			int16_t;
typedef unsigned short		uint16_t;
typedef int			int32_t;
typedef unsigned int		uint32_t;
typedef long long		int64_t;
typedef unsigned long long	uint64_t;

// size_t is used for memory object sizes.
typedef uint32_t size_t;
// ssize_t is a signed version of ssize_t, used in case there might be an
// error return.
typedef int32_t ssize_t;

// off_t is used for file offsets and lengths.
typedef int32_t off_t;

typedef uint32_t physaddr_t;	// physical address type
typedef uint32_t uintptr_t;	// virtual address type
// Efficient min and max operations
#define MIN(_a, _b)	((_a) < (_b) ? (_a) : (_b))
#define MAX(_a, _b)	((_a) < (_b) ? (_b) : (_a))

// Rounding operations (efficient when n is a power of 2)
// Round down to the nearest multiple of n
#define ROUNDDOWN(a, n)	(((uint32_t)(a)) - (((uint32_t)(a)) % (n)))
#define ROUNDUP(a, n)	ROUNDDOWN(((uint32_t)(a)) + (n) - 1, n)

#define offsetof(type, member)  ((size_t) (&((type*)0)->member))

#endif /* SATURNOS_INC_TYPES_H */

